<template>
  <div class="dashboard-editor-container">

    <panel-group @handleSetLineChartData="handleSetLineChartData" />

    <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <line-chart :chart-data="lineChartData" />
    </el-row>

    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8">
         <el-card class="box-card" :body-style="{ padding: '0px' }">
          <div slot="header" class="clearfix">
            <span>我的课表</span>
          </div>
          <teach-schedule />
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <el-card class="box-card" :body-style="{ padding: '0px' }">
          <div slot="header" class="clearfix">
            <span>校园公告</span>
          </div>
          <school-notice />
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <el-card class="box-card" :body-style="{ padding: '0px' }">
          <div slot="header" class="clearfix">
            <span>学校荣耀</span>
          </div>
          <school-glory />
        </el-card>
      </el-col>
    </el-row>    
  </div>
</template>

<script>
import { apiDs } from "@/api/openapi";

import PanelGroup from './dashboard/PanelGroup'
import LineChart from './dashboard/LineChart'
import SchoolNotice from "./dashboard/SchoolNotice";
import TeachSchedule from "./dashboard/TeachSchedule";
import SchoolGlory from './dashboard/SchoolGlory.vue';

export default {
  name: 'Index',
  components: {
    PanelGroup,
    LineChart,
    SchoolNotice,
    TeachSchedule,
    SchoolGlory
  },
  data() {
    return {
      lineChartData: []
    }
  },
  created() {
    this.handleSetLineChartData('line1');
  },
  methods: {
    handleSetLineChartData(type) {      
      apiDs('home_statics_'+type).then(response=>{
        this.lineChartData = response.data;
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
